<template>
  <div class="rout">
    <baidu-map center="合肥市" :scroll-wheel-zoom="true">
      <bm-overview-map
        anchor="BMAP_ANCHOR_BOTTOM_RIGHT"
        :isOpen="true"
      ></bm-overview-map>
      <bm-city-list anchor="BMAP_ANCHOR_TOP_LEFT" offset="500"></bm-city-list>
      <bm-traffic :predictDate="{ weekday: 7, hour: 12 }" v-if="value">
      </bm-traffic>
      <bm-view class="map">
        <bm-scale anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-scale>
      </bm-view>

     
        <bm-driving
          :start="searchRouter.start"
          :end="searchRouter.end"
          :auto-viewport="true"
          :waypoints="searchRouter.waypoints"
        ></bm-driving>
        
   
    </baidu-map>

    <!-- 获取 -->
    <div class="getDriveInfo">
      <ul>
        <li>起点 <el-input type="text" v-model="myRouter.start"></el-input></li>
        <li>终点 <el-input type="text" v-model="myRouter.end"></el-input></li>
        <li>
          途经1
          <el-input type="text" v-model="myRouter.waypoints[0]"></el-input>
        </li>
        <li>
          途经2
          <el-input type="text" v-model="myRouter.waypoints[1]"></el-input>
        </li>
        <li>
          途经3
          <el-input type="text" v-model="myRouter.waypoints[2]"></el-input>
        </li>
      </ul>
      <el-button
        style="position: absolute; z-index: 10; top: 10px; right: 90px"
        @click="getRoute"
        >获取</el-button
      >
    </div>

    <el-button style="position: absolute; z-index: 10; top: 50px; right: 50px"
      >显示交通流量</el-button
    >
    <el-switch
      v-model="value"
      active-color="#13ce66"
      inactive-color="#ff4949"
      style="position: absolute; z-index: 10; top: 60px; right: 180px"
    >
      显示交通流量
    </el-switch>
  </div>
</template>

<script>
export default {
  name: "rout",
  data() {
    return {
      myRouter: {
        start: "",
        end: "",
        startCity: "",
        endCity: "",
        waypoints: [],
      },
      value: true,
      searchRouter: {},
     
    };
  },
  methods: {
    getRoute() {
      console.log(this.searchRouter);
      this.searchRouter = null;
      this.drawer=true;
      this.searchRouter = Object.assign(this.myRouter);
    },
   
  },
};
</script>

<style scoped>
.rout {
  width: 100%;
  height: 100%;
}
.map {
  width: 100%;
  height: 700px;
}
.getDriveInfo {
  width: 250px;
  height: 500px;
  position: absolute;

  top: 50px;
  left: 40px;
  z-index: 10;
  background: white;
  box-shadow: 2px 2px 2px rgb(236, 235, 235), -2px -2px 2px rgb(236, 235, 235),
    -2px 2px 2px rgb(236, 235, 235), 2px -2px 2px rgb(236, 235, 235);
}

.getDriveInfo ul {
  width: 100%;
  height: 100%;
}
.getDriveInfo ul li {
  width: 100%;
  height: 20px;
  margin: 20px 0;
  list-style: none;
  position: relative;
  margin: 60px 0;
  padding: 0 20px;
  box-sizing: border-box;
}
</style>